{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "DRA",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "id" : {
      "type" : "integer",
      "description" : "Unique identifier for each generic extract file that is produced by CMP."
    },
    "interfaceCategory" : {
      "type" : "string",
      "enum" : [ "Credit Management" ],
      "description" : "CMP categorisation of the job associated with this file."
    },
    "interfaceType" : {
      "type" : "string",
      "enum" : [ "Debt Recovery Extract" ],
      "description" : "Sub-categorisation of the job"
    },
    "version" : {
      "type" : "number",
      "minimum" : 1.0,
      "maximum" : 1.0,
      "description" : "The current version of the generic extract file. This must match the corresponding inbound file."
    },
    "batchDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the batch was created in CMP. "
    },
    "extractDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Timestamp indicating when the generic extract file was created."
    },
    "recordCount" : {
      "type" : "integer",
      "minimum" : 0,
      "description" : "Total number of transaction records in the extract file. "
    },
    "isoCurrencyCode" : {
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9]+$",
      "minLength" : 3,
      "maxLength" : 3,
      "description" : "The iso currency code"
    },
    "companyId" : {
      "type" : "string",
      "maxLength" : 30,
      "description" : "The company identifier"
    },
    "companyType" : {
      "type" : "string",
      "maxLength" : 3,
      "description" : "The company type"
    },
    "sender" : {
      "type" : "string",
      "maxLength" : 3,
      "description" : "The sender name"
    },
    "placement" : {
      "type" : "integer",
      "minimum" : 1,
      "maximum" : 9,
      "description" : "The placement"
    },
    "totalBalanceToRecover" : {
      "type" : "number",
      "minimum" : 0.0,
      "maximum" : 9.9999999999E8,
      "description" : "The total balance to recover"
    },
    "isNewAccounts" : {
      "type" : "boolean",
      "description" : "Indicates if this is a new account"
    },
    "accountType" : {
      "type" : "string",
      "description" : "This indicates the CMP account type that is being extracted."
    },
    "accounts" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Account"
      }
    }
  },
  "required" : [ "id", "interfaceCategory", "interfaceType", "version", "batchDateTime", "extractDateTime", "recordCount", "isoCurrencyCode", "companyId", "companyType", "sender", "placement", "totalBalanceToRecover", "isNewAccounts", "accountType" ],
  "definitions" : {
    "Account" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "accountId" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 99999999,
          "description" : "the unique identifier for the account."
        },
        "postalAddress" : {
          "$ref" : "#/definitions/PostalAddress"
        },
        "telephoneNumbers" : {
          "$ref" : "#/definitions/TelephoneNumbers"
        },
        "emails" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Email"
          }
        },
        "extractStatus" : {
          "type" : "string",
          "enum" : [ "OPEN", "CLOSED" ],
          "description" : "This indicates the extractStatus of the account. Open means that it will be extracted again where as Closed means that is has been extracted for the final time."
        },
        "remainingBalanceToRecover" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : "The remaining balance that the DRA needs to recover from the customer."
        },
        "paymentsReceivedSinceLastExtract" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : "This is the total amount of payments that have been made for the specified account since the extract was last run."
        },
        "dateAccountEnteredCreditControl" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "this is the date that the account entered credit control."
        },
        "accountCreationDate" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "This is the date that the account was created. The time element will always be 00:00:00"
        }
      },
      "required" : [ "accountId", "postalAddress", "extractStatus", "remainingBalanceToRecover", "paymentsReceivedSinceLastExtract", "dateAccountEnteredCreditControl", "accountCreationDate" ]
    },
    "PostalAddress" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "formattedName" : {
          "type" : "string",
          "maxLength" : 60,
          "description" : "This is a formatted name which includes title, forname, middle name and surname. If the address is a company address it will put the company name in here instead."
        },
        "title" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The title of the customer e.g. Mr, Mrs etc"
        },
        "foreName" : {
          "type" : "string",
          "maxLength" : 50,
          "description" : "The customers first name"
        },
        "middleName" : {
          "type" : "string",
          "maxLength" : 20,
          "description" : "The customers middle name"
        },
        "surname" : {
          "type" : "string",
          "maxLength" : 50,
          "description" : "The customers surname."
        },
        "companyName" : {
          "type" : "string",
          "maxLength" : 60,
          "description" : "The name of hte company. Only applicable when the address is stored as a company address in CMP."
        },
        "postCode" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The customers post code."
        },
        "addressLines" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/AddressLine"
          },
          "description" : "Lines of the address."
        }
      },
      "required" : [ "formattedName", "addressLines" ]
    },
    "AddressLine" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "line" : {
          "type" : "string",
          "maxLength" : 60
        }
      }
    },
    "TelephoneNumbers" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "telephoneNumber1" : {
          "type" : "string",
          "maxLength" : 15,
          "description" : "The value stored in the Telephone number 1 field in CMP. This may vary depending on the CMP implementation."
        },
        "telephoneNumber2" : {
          "type" : "string",
          "maxLength" : 15,
          "description" : "The value stored in the Telephone number 2 field in CMP. This may vary depending on the CMP implementation."
        },
        "telephoneNumber3" : {
          "type" : "string",
          "maxLength" : 15,
          "description" : "The value stored in the Telephone number 3 field in CMP. This may vary depending on the CMP implementation."
        }
      }
    },
    "Email" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "type" : {
          "type" : "string",
          "maxLength" : 6,
          "description" : "The email address type is configurable but often is set to HOME or WORK."
        },
        "value" : {
          "type" : "string",
          "maxLength" : 70,
          "description" : "The value field contains the actual e mail address."
        },
        "isPrimary" : {
          "type" : "boolean",
          "description" : "The isPrimaryEMAil field indicates whether this is a customers primary email or not."
        }
      }
    }
  }
}